package com.hspedu.static_;

public class StaticExercise02 {
}
class PPerson {  //StaticExercise02.java 2min 时间
    private int id;
    private static int total = 0;
    public static int getTotalPerson() {
        //id++;//错误, 注销

        return total;
    }
    public PPerson() {//构造器
        total++;  //total = 1
        id = total;//id = 1
    }
}
class TTestPerson {
    public static void main(String[] args) {
        System.out.println("Number of total is " +PPerson.getTotalPerson()); //0
        PPerson p1 = new PPerson();
        System.out.println( "Number of total is "+ PPerson.getTotalPerson()); //1
    }
}
